package m3;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

/**
 * 路由
 * @author 郭鲁政
 */
public class Prouder {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("192.168.64.140");
        connectionFactory.setPort(5672);
        connectionFactory.setUsername("admin");
        connectionFactory.setPassword("admin");
        Channel channel = connectionFactory.newConnection().createChannel();
        /**
         * 1.队列名字
         * 2.是否持久化
         * 3.是否是独占队列
         * 4.没用时是否删除
         * 5.其他参数
         */
      //  channel.exchangeDeclare("test-2", BuiltinExchangeType.FANOUT,false,false,null);
        while (true){
            System.out.println("请输入");
            String s = new Scanner(System.in).nextLine();
            channel.basicPublish("test-3", "12", null, s.getBytes());
        }
    }
}
